package com.bw.goods.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bw.goods.entity.LogisticsEntity;
import com.bw.goods.service.LogisticsService;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.R;



/**
 * 物流表 
 *
 * @author wj
 * @email sunlightcs@gmail.com
 * @date 2021-08-22 21:41:50
 */
@RestController
@RequestMapping("goods/logistics")
public class LogisticsController {
    @Autowired
    private LogisticsService logisticsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = logisticsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{logisticsId}")
    public R info(@PathVariable("logisticsId") Integer logisticsId){
		LogisticsEntity logistics = logisticsService.getById(logisticsId);

        return R.ok().put("logistics", logistics);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody LogisticsEntity logistics){
		logisticsService.save(logistics);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody LogisticsEntity logistics){
		logisticsService.updateById(logistics);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] logisticsIds){
		logisticsService.removeByIds(Arrays.asList(logisticsIds));

        return R.ok();
    }

}
